#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX_NUM         100
#define MAX_MEMBER_NUM  2
#define MAX_STR_LEN     100

int GetJudge(int n, int array[][MAX_MEMBER_NUM], int len)
{
    int i;
    char trusted[MAX_NUM][MAX_MEMBER_NUM] = {0}; 
    if (n >= MAX_NUM) {
        return -1;
    }
    for (i = 0; i < len; i++) {
        trusted[array[i][0]][0]++;
        trusted[array[i][1]][1]++;
    }
    for (i = 1; i <= n; i++) {
        // trust 0, trusted n-1
        if (trusted[i][0] == 0 && trusted[i][1] == n-1) {
            return i;
        }
    }
    return -1;
}

/*
examples:

2
[[1,2]]
=> 2

3
[[1,3],[2,3]]
=> 3

3
[[1,3],[2,3],[3,1]]
=> -1

3
[[1,2],[2,3]]
=> -1

4
[[1,3],[1,4],[2,3],[2,4],[4,3]]
=> 3
*/
int main(void)
{
    int n = 0;
    char trust[MAX_STR_LEN] = {0};
    int array[MAX_NUM][MAX_MEMBER_NUM] = {0};
    int index = 0;

    scanf("%d", &n);
    scanf("%100s", trust); // 100 is max str len

    int len = strlen(trust);
    if (n < 2 || len < 7) { // [[1,2]], 2 and 7 are count
        return -1;
    }
    /**
     *  [[1,2],[3,4]]
     *  |  |
     *  |  `--head
     *   `--tail
     */
    char *head = trust;
    char *tail = trust;
    while (*head != '\0') {
        if (*head == '[') {
            head++; tail++;
        } else if (*head == ']') {
            if (head != trust && *(head-1) != ']') {
                char *tmp = tail;
                while (*tmp != ',' && tmp < head - 1) tmp++;
                *tmp = '\0'; *head = '\0';
                if (index < MAX_NUM) {
                    array[index][0] = atoi(tail);
                    array[index][1] = atoi(tmp+1);
                    index++;
                }
                head++;
                while (*head != '[' && *head != '\0') head++;
                tail = head;
            } else {
                head++;
            }
        } else {
            head++;
        }
    }

    printf("%d", GetJudge(n, array, index));
    // printf("\n");

    return 0;
}
